package com.linwen.javase.desgin_pattern.BigTalkDesignPattenJAVACode._03装饰模式._6装饰器_策略工厂;

/**
 * @ClassName CashReturn
 * @Description TODO
 * @Author zero
 * @DATE 2023/7/10 11:20 PM
 * @Version 1.0
 */
public class CashReturn extends CashSuper implements ISale {
    private double moneyCondition = 0d;
    private double moneyReturn = 0d;
    public CashReturn(double moneyCondition, double moneyReturn) {
        this.moneyReturn = moneyReturn;
        this.moneyCondition = moneyCondition;
    }

    @Override
    public double acceptCash(double price, int num) {
        double result = price*num;
        if(moneyCondition>0){
            result -= Math.floor(result/moneyCondition)*moneyReturn;
        }
        return super.acceptCash(result,1);
    }
}
